package com.xgggh.redpack.ui.login;

import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;

import android.text.TextUtils;
import android.view.View;

import com.uber.autodispose.AutoDispose;
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
import com.xgggh.redpack.BuildConfig;
import com.xgggh.redpack.R;
import com.xgggh.redpack.base.ui.BaseActivity;
import com.xgggh.redpack.databinding.ActivityLeanStartUpBinding;
import com.xgggh.redpack.domain.auth.Auth;
import com.xgggh.redpack.ui.home.NavHomeActivity;
import com.xgggh.redpack.ui.map.MapActivity;
import com.xgggh.redpack.ui.redpack.CategoryActivity;
import com.xgggh.redpack.ui.redpack.RedPackActivity;
import com.xgggh.redpack.utils.AuthManager;

import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

import dagger.android.AndroidInjection;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;

public class StartUpActivity extends BaseActivity {
    ActivityLeanStartUpBinding mBinding;
    @Inject
    Auth auth;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        AndroidInjection.inject(this);

        super.onCreate(savedInstanceState);
        mBinding= DataBindingUtil.setContentView(this,R.layout.activity_lean_start_up);
        if (!isTaskRoot()){
            finish();
        }
        //AuthManager.init(getSharedPreferences(), AuthManager.Token);

        Observable.just(0)
                .as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this)))
                .subscribe(aLong -> startPage());
    }

    private void  startPage(){
        boolean _auth = TextUtils.isEmpty(auth.getAccessToken());
        //_auth= BuildConfig.DEBUG?_auth:!_auth;

        startActivity(new Intent(this, NavHomeActivity.class));

        /*if (_auth){
            startActivity(new Intent(this,LoginActivity.class));
        }else{
            startActivity(new Intent(this, NavHomeActivity.class));
        }*/
        //startActivity(new Intent(this, NavHomeActivity.class));
        finish();
    }

}
